#!/bin/bash  

name=$1
lang=$2
if [ ! $1 ]|| [ ! $2 ]; then
	echo '参数不对'
    exit 0
fi

values="values"
if [[ ! $lang =~ "en" ]]; then
	if [[  $lang =~ "zh" ]]; then
		lang=${lang//-tw/-rTW}
		lang=${lang//-hk/-rHK}
		lang=${lang//-cn/}
	else
		lang=${lang: 0: 2}
	fi	

values=values-${lang}

fi
root=$(cd `dirname $0`; pwd)
path=${root}/src/main/res/${values}
echo $path
if [ ! -d $path ];then
	echo '目录不存在'
fi

a=`uname  -a`
mac="Darwin"
rep="s#iCam365#"${name}"#g"
file=${path}/strings.xml
file2=${path}/strings-archive.xml
echo $file
if [[ $a =~ $mac ]];then
  sed -i "" ${rep}  $file
  sed -i "" ${rep}  $file2
else
   sed -i  ${rep}  $file
   sed -i  ${rep}  $file2
fi

if [[ ! $values =~ "-" ]]; then
file=${root}/../app/src/main/res/${values}/strings.xml
file2=${root}/../app/src/main/res/${values}/strings-archive.xml
echo $file
echo $file2
if [[ $a =~ $mac ]];then
  sed -i "" ${rep}  $file
  sed -i "" ${rep}  $file2
else
   sed -i  ${rep}  $file
   sed -i  ${rep}  $file2
fi
fi
